package com.pilhun.parser;

class ArgumentEntry {
	private String name;
	private String argument;
	private ArgumentType type;

	public ArgumentEntry(String name, String argument, ArgumentType type) {
		this.name = name;
		this.argument = argument;
		this.type = type;
	}

	public ArgumentEntry(String argument, ArgumentType type) {
		this.argument = argument;
		this.type = type;
	}

	public Boolean isRef() {
		return type == ArgumentType.REFERENCE;
	}

	public Boolean isVal() {
		return type == ArgumentType.VALUE;
	}

	public String getName() {
		return name;
	}

	public String getArgument() {
		return argument;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((argument == null) ? 0 : argument.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj){
			return true;
		}
		if (obj == null){
			return false;
		}
		if (getClass() != obj.getClass()){
			return false;
		}
		ArgumentEntry other = (ArgumentEntry) obj;
		if (argument == null) {
			if (other.argument != null){
				return false;
			}
		} else { 
			if (!argument.equals(other.argument)){
				return false;
			}
		}
		if (name == null) {
			if (other.name != null){
				return false;
			}
		} else { 
			if (!name.equals(other.name)){
				return false;
			}
		}
		if (type != other.type){
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "ArgumentEntry [name=" + name + ", argument=" + argument
				+ ", type=" + type + "]";
	}

}
